<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    // 1,  不改变原数组, 取出数组[3,2,4,5,8,6,3,9]中的[5,8,6].
        var arr1=[3,2,4,5,8,6,3,9];
        console.log(arr1.slice(3,6));
        console.log("---------------------------");


    // 2, 在数组[1,2,3,4,6,7,8]中对应的位置插入5, 变成[1,2,3,4,5,6,7,8]
    var arr2=[1,2,3,4,6,7,8];
    arr2.splice(4,0,5);
    console.log(arr2);
    console.log("-------------------------------");


    // 3, 将数组 ["我","是","一","只","笨","鸟"] 改成 ["我","是","一","只","聪","明","鸟"], 并打印出: "我是一只聪明鸟"
    var arr3=["我","是","一","只","笨","鸟"];
    arr3.splice(4,1,"聪","明");
    console.log(arr3.join(""));
    console.log("-------------------------------");


    // 4, 删除数组[20,23,21,34,54,55,32]中的倒数第二个和倒数第三个元素
    var arr4=[20,23,21,34,54,55,32];
    arr4.splice(4,2);
    console.log(arr4);

    </script>
</body>
</html>